{% extends "./inc/appbase.html" %}
{%block style%}
<style>
    .mui-table h4 ,.mui-media-body h4{
        line-height: 21px;
        font-weight: 400;
    }
</style>
{%endblock%}
{% block content %}
<header class="mui-bar mui-bar-nav">
    <a  href="/center/club/account/?clubid={{club_id}}" class="mui-icon mui-icon-left-nav mui-pull-left"></a>
    <h1 class="mui-title">{{controller.meta_title}}</h1>
</header>
<div class="mui-content">
    <form method="post" class="form-recharge">
    
        <div class="mui-card">
        <ul class="mui-table-view ">
                
                <li class="mui-table-view-divider">每位成员每天最多可消耗</li>
                <div class="mui-input-row padding-10">
                    <input type="number" pattern="\d*" placeholder="输入数量" name="dailyCard" min="1">
                </div>
                <li class="mui-table-view-divider">俱乐部房卡过低提醒数量</li>
                <div class="mui-input-row padding-10">
                    <input type="number" pattern="\d*" placeholder="输入数量" name="warnCard" min="1">
                </div>
            </ul>
         </div>
        <div class="mui-content-padded" style="margin-top: 20px; margin-bottom: 50px">
            <button type="button" class="mui-btn mui-btn-primary mui-btn-block" id="setting">设置</button>
        </div>
    </form>
</div>

{% endblock%}

{% block script %}
<script>
    var falg = false;
    var club_id = "{{club_id}}";
    $("#setting").on("tap",function () {
    	var that = this;
    	//var clubsmn ="{{clubsmn}}";
    	//var card_count = "{{userInfo.card_count}}";
        var dailyCard = $("input[name='dailyCard']").val();
        var warnCard = $("input[name='warnCard']").val();
        
        if(dailyCard===''){
            mui.toast("请输入每位成员每天最多可消耗数量！");
            return;
        }
        
        if(warnCard===''){
            mui.toast("请输入俱乐部房卡过低提醒数量！");
            return;
        }
        
        
    	
        var btnArray = ['否', '是'];
        mui.confirm('是否确认设置？', '', btnArray, function(e) {
            if (e.index == 1) {
                //获取id
            	if(falg){
                    return false;
                }
            	
                
                $(that).addClass('disabled').attr('autocomplete','off').prop('disabled',true);
                falg = true;
                
                mui.post("/center/club/setting",
                		{dailyCard:dailyCard,
                	     warnCard:warnCard,
                	     clubid:club_id
                	   },
                		function(data){
                	if(data.errno == 0){
                        mui.toast(data.data.name);
                        setTimeout(function(){
                            $(that).removeClass('disabled').prop('disabled',false);
                            falg=false;
                            //mui.back();
                            location.href="/center/club/account/?clubid={{club_id}}";
                        },1500);
                    }else {
                        if(data.errno==1001){
                            $.each(data.errmsg,function(i,n){
                                mui.toast(n);
                            })
                        }else {
                            mui.toast(data.errmsg);
                        }
                        setTimeout(function(){
                            $(that).removeClass('disabled').prop('disabled',false);
                            falg=false;
                        },1500);
                    }
                },'json');
            }
        })
        return false;
        
        
    })
</script>
{% endblock %}
